package cn.melon.view.control;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import javax.swing.JFrame;

/**
 * @ClassName: MouseDraggedAdapter
 * @author Hzy
 * 监听器，在窗口鼠标拖动时对应设置窗口位置。
 */
public class MouseDraggedAdapter implements MouseMotionListener{
	private JFrame window;
	private Point origin;
	public MouseDraggedAdapter(JFrame window,Point origin){
		this.window = window;
		this.origin = origin;
	}
	
	@Override
	public void mouseDragged(MouseEvent e){
		Point currentLocation = window.getLocation();
		window.setLocation(currentLocation.x + e.getX() - origin.x, currentLocation.y + e.getY() - origin.y);
	}
	@Override 
	public void mouseMoved(MouseEvent e){
//		Do nothing
	}
}
